package com.service.system.agent.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.SystemGlobalConfigMapper;
import com.entity.system.SystemGlobalConfig;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.system.agent.SystemGlobalConfigService;
import com.util.Const;

@Service
public class SystemGlobalConfigServiceImpl implements SystemGlobalConfigService {

	@Autowired
	SystemGlobalConfigMapper systemGlobalConfigMapper;
	
	@Override
	public Map<String, Object> findAgentConfigList(Map<String, String> map) {
		Map<String ,Object> map1 = new HashMap<>();
		int pageNum = 1;
        int pageSize = 10;
        if(StringUtils.isNotEmpty(map.get("pageNum"))){
           pageNum = Integer.parseInt(map.get("pageNum"));
        }
        if(StringUtils.isNotEmpty(map.get("pageSize"))){
            pageSize = Integer.parseInt(map.get("pageSize"));
        }
        PageHelper.startPage(pageNum,pageSize);
		List<SystemGlobalConfig> agentConfigList = systemGlobalConfigMapper.selectAgentConfigList(map);
		
		PageInfo<SystemGlobalConfig> pageInfo = new PageInfo<>(agentConfigList);
        map1.put("code", Const.SUCCESS_CODE);
        map1.put("message","查询成功");
        map1.put("agentConfigList",agentConfigList);
        map1.put("page",pageInfo);
		return map1;
	}

	@Override
	public SystemGlobalConfig findAgentConfigById(int id) {
		return systemGlobalConfigMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateAgentConfig(SystemGlobalConfig systemGlobalConfig) {
		return systemGlobalConfigMapper.updateByPrimaryKeySelective(systemGlobalConfig);
	}

	
}
